// <copyright file="InstructionWithOCLAndVariable.cs" company="Codeplex project Eco.Contrib"> 
// The MIT License (MIT) 
// </copyright> 
// <author>Peter Buchmann</author> 

namespace Eco.Contrib
{
    using Eco.ObjectRepresentation;
    using Eco.Services;
    using Eco.UmlCodeAttributes;

    /// <summary>
    /// InstructionWithOCLAndVariable: Instruction that represents a Instruction with OCL and variable
    /// </summary>
    public partial class InstructionWithOclAndVariable
    {
        /// <summary>
        /// Sets the variable.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="variableList">The variable list.</param>
        /// <param name="element">The element.</param>
        [UmlElement(Id = "8da8ca40-3b3c-47e9-9543-916ab0144d94")]
        public void SetVariable(IEcoServiceProvider serviceProvider, IModifiableVariableList variableList, IElement element)
        {
            if (this.ResultVariable != null)
            {
                if (element == null)
                {
                    element = serviceProvider.GetEcoService<IVariableFactoryService>().NullReference;
                }

                this.ResultVariable.Set(variableList, element);
            }
        }
    }
}